package com.shuyu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shuyu.common.core.domain.entity.Customer;
import com.shuyu.domain.CustomerAssets;
import com.shuyu.vo.CustomerAssetsVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CustomerAssetsMapper extends BaseMapper<CustomerAssets> {

    @Select("SELECT t1.*,t2.id,t2.username,t2.nickname,t2.point from (" +
            "select customer_id," +
            "GROUP_CONCAT(case product_type when 1 then t2.name else null end) as nft," +
            "GROUP_CONCAT(case product_type when 2 then t2.name else null end) as card," +
            "GROUP_CONCAT(case product_type when 3 then t2.name else null end) as mv," +
            "GROUP_CONCAT(case product_type when 4 then t2.name else null end) as internal_assets," +
            "GROUP_CONCAT(case product_type when 5 then t2.name else null end) as external_assets " +
            "from (" +
            "select product_id,customer_id,product_type from  tbl_customer_assets GROUP BY product_id,customer_id,product_type " +
            ")t1 left join tbl_product t2 on t1.product_id=t2.id " +
            "GROUP BY customer_id " +
            ") t1 LEFT JOIN tbl_customer t2 on t1.customer_id=t2.id  ${condition}")
    List<Customer> getCustomerAssets(String condition);

}
